<!DOCTYPE html>
<html lang="zh-cn">
<head>
<#include "/common/freemarker/include_css.ftl">
<title>菜单管理</title>
</head>
<body>
 

<link rel="stylesheet" type="text/css" href="<@context/>common/jquery-plugins/zTree/css/zTreeStyle/zTreeStyle.css" />


<div class="row ">		 
	
    <div class="col-md-2" style="min-width: 400px;">
		<div class="panel panel-default">
		    <div class="panel-heading">
		                  菜单树  <span  style="float:right"><a href="javascript:doSynButton()">更新公众号菜单</a></span>
		    </div>
		    <div class="panel-body"  >
		        
				<ul id="tree" class="ztree" style="width:260px; overflow:auto;"></ul>
		    </div>
		
		
		    <div class="panel-footer">
		        
		    </div>
		</div>  
	</div>
	
		    
    <div class="col-md-6">
    
		<div class="panel panel-default">
		    <div class="panel-heading">
		                        菜单信息
		    </div>
		    <div class="panel-body" id="edit_block">
					 
					<#include "edit.ftl">

		    </div>
		    <div class="panel-footer">
		        
		    </div>
		</div>      
    </div>
</div>  
<#include "/common/freemarker/include_js.ftl">
<script type="text/javascript" src="<@context/>common/jquery-plugins/zTree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<@context/>js/mindao/mindao.tree.js"></script>
	
  
 <SCRIPT type="text/javascript" >
	var zTree;
	var setting = {
		view: {
			dblClickExpand: false,
			showLine: true,
			selectedMulti: false
		},
		data: {
			simpleData: {
				enable:true,
				idKey: "id",
				pIdKey: "pId",
				rootPId: ""
			}
		}
	};
 
	<#if treeNodes?exists> 
		var zNodes =  JSON.parse('${treeNodes}');
	<#else>
		var zNodes =  [];
	</#if>
	$(document).ready(function(){
		var t = $("#tree");
		t = $.fn.zTree.init(t, setting, zNodes);
		var zTree = $.fn.zTree.getZTreeObj("tree");
		<#if selectNodeId?exists>
			zTree.selectNode(zTree.getNodeByParam("id", ${selectNodeId}));
		</#if>
	});
	
	
	 
	function doEditTree(id, pId) {
	   
		var options = {
			url : "<@context/>weixin/wxmpbutton/edit.do",
			data : {"id": id,"pId":pId}, 
			editBlockName : 'edit_block',
			callBack : function(response) {
				
			}
		};
		comm_editInfo(options);
	}
	
	function doSynButton(){
	 
  
		 $.ajax({
			type: "POST",
			url: "<@context/>/weixin/wxmpbutton/doSynButton.do",
			data: {},
			dataType:"json",//返回类型
			cache: false,
			success: function(jsonData){
			    //alert(html);
			    if (jsonData.status=="success"){
					 alert("更新公众号菜单成功");
				}else{
					alert(jsonData.message);
				}
			}
		 });
	}
	 
  </SCRIPT>	
  
</body>
</html>
